//点击返回顶部
let scrolltop = document.documentElement.scrollTop
$("#foot ul .li3").click(function () {
    $("html,body").animate({ scrollTop: 0 }, 500)
})
//点击返回图标返回首页
$("#header .fh").click(function(){
    window.location.href="../index.html"
})
//请求数据渲染页面
fetch("http://chst.vip:1234/api/getinlanddiscount")
.then(body=>body.json())
.then(res=>{
    let resultarr = res.result
    let str=""
    resultarr.forEach(item => {
        str+=`
        <div class="boxpb">
        ${item.productImg}
        <p class="jieshao" productId="${item.productId}">
        ${item.productName}
        </p>
        <p class="jiage">
        ${item.productPrice}
        </p>
        <p class="laiyuan">
        ${item.productFrom}|${item.productTime}
        </p>
        </div>                
        `
    });
    $("#main .lis li").html(str)
    //点击跳转详情页 query传参productId
    $("#main .lis li").on("click",".boxpb>img",function(e){
        let _this = e.target
        let productId = $(_this).next().attr("productId")
        console.log(productId);
        window.location.href=`gnzk_detail.html?productid=${productId}`
    })
})